package com.webservice.xmloper.monitorLogResult;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import com.thoughtworks.xstream.XStream;
import com.webservice.command.utils.Constant;

public class MonitorLogOper {
	
	/**
	 * 解析监测日志xml文件 
	 */
	public static MonitorLogResult parseMonitorLogXml(String xmlString){
		MonitorLogResult monitorLogResult = null;
		XStream xs = new XStream();
		xs.processAnnotations(MonitorLogResult.class);
		try {
			InputStream myIn = new ByteArrayInputStream(xmlString.getBytes(Constant.CHARACTER_SET));
			monitorLogResult = (MonitorLogResult) xs.fromXML(myIn);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return monitorLogResult;
	}

	
	public static String createMonitorLogXml(MonitorLogResult monitorResult){
		XStream xs = new XStream();
		xs.processAnnotations(MonitorLogResult.class);
		return xs.toXML(monitorResult);
	}
	
}
